<template>
  <el-card class="app-container">
    <c-u-r-d-table :option="option"/>
    <comment-list-dialog :showed.sync="commentDialogShowed" :business-id="currentRow.id" :business-type="1"/>
  </el-card>
</template>

<script>

import ColumnType from '@/framework/constant/ColumnType'
import { topicApi } from '@/feature/cms/infra/api/topicApi'
import CURDTable from '@/framework/components/table/CURDTable'
import CommentListDialog from '@/feature/cms/components/CommentListDialog'
import OnlineStatusEnum from '@/framework/constant/OnlineStatusEnum'

export default {
  components: { CommentListDialog, CURDTable },
  data() {
    return {
      currentRow: {},
      commentDialogShowed: false,
      option: {
        requestApi: topicApi,
        initListParams() {
          return {
            sortType: 0
          }
        },
        columns: [
          {
            label: 'ID',
            width: 60,
            prop: 'id'
          },
          {
            label: '圈主姓名',
            searchable: true,
            width: 150,
            required: true,
            prop: 'anchor.nickName'
          }, {
            label: '圈主头像',
            searchable: true,
            width: 120,
            type: ColumnType.IMAGE,
            required: true,
            prop: 'anchor.headImg'
          }, {
            label: '圈主电话',
            searchable: true,
            width: 120,
            required: true,
            prop: 'anchor.telephone'
          },
          {
            label: '标题',
            searchable: true,
            width: 300,
            required: true,
            prop: 'title'
          },
          {
            label: '话题简介',
            prop: 'intro',
            width: 400
          },
          {
            label: '收藏数',
            prop: 'collectedCount',
            width: 80,
            type: ColumnType.NUMBER
          },
          {
            label: '排序',
            width: 80,
            span: 24,
            required: true,
            prop: 'sortNum',
            type: ColumnType.NUMBER
          },
          {
            label: '评论数',
            width: 80,
            prop: 'commentCount',
            type: ColumnType.NUMBER
          },
          {
            label: '浏览数',
            width: 80,
            prop: 'viewedCount',
            type: ColumnType.NUMBER
          },
          {
            label: '状态',
            width: 100,
            searchable: true,
            type: ColumnType.RADIO,
            hiddenInForm: true,
            options: OnlineStatusEnum,
            prop: 'status'
          },
          {
            label: '话题封面',
            type: ColumnType.IMAGE,
            prop: 'cover'
          },
          {
            label: '创建时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtCreate'
          },
          {
            label: '修改时间',
            type: ColumnType.DATETIME,
            hiddenInForm: true,
            prop: 'gmtModified'
          }
        ]
      }
    }
  },
  methods: {
    handleComment({ arg }) {
      this.currentRow = arg
      this.commentDialogShowed = true
    }
  }
}
</script>

